package com.zhixue.content.controller;

import com.zhixue.content.model.dto.CourseTeacherDto;
import com.zhixue.content.model.po.CourseTeacher;
import com.zhixue.content.service.CourseTeacherService;
import com.zhixue.r.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: 李 力
 * @Date: 2025/4/11
 * @Description: com.zhixue.content.controller
 * @version: 1.0
 */
@RestController
@RequestMapping
public class CourseTeacherController {

    @Autowired
    private CourseTeacherService teacherService;

    //新增教师
    @PostMapping("/courseTeacher")
    public CourseTeacher addTea(@RequestBody CourseTeacherDto teacherDto) {
        return teacherService.addTea(teacherDto);
    }

    //根据课程ID查询教师
    @GetMapping("/courseTeacher/list/{id}")
    public List<CourseTeacher> selectByCourseId(@PathVariable("id") Long id) {
        return teacherService.selectByCourseId(id);
    }

    //修改教师信息
    @PutMapping("/courseTeacher")
    public CourseTeacher updateTea(@RequestBody CourseTeacher courseTeacher) {
        return teacherService.updateTea(courseTeacher);
    }

    //删除教师信息
    @DeleteMapping("/ourseTeacher/course/{courseId}/{teaId}")
    public R deleteTea(@PathVariable Long courseId, @PathVariable Long teaId) {
        return teacherService.deleteTea(courseId, teaId);
    }
}
